package com.ebocy.hammer.core.socket.client;
import org.apache.log4j.Logger;
import org.apache.mina.core.service.IoHandlerAdapter;
import org.apache.mina.core.session.IoSession;

import com.ebocy.hammer.core.handler.HandlerManager;
import com.ebocy.hammer.core.log.EbocyLogManager;
import com.ebocy.hammer.core.message.AbstractC2SMessage;

public class ClientIoHandler extends IoHandlerAdapter {
	private static Logger logger = EbocyLogManager.getSystemLogger();
	@Override
	public void sessionOpened(IoSession session) throws Exception {
//		logger.info("受管理的连接数：" + acceptor.getManagedSessionCount());
	}


	@Override
	public void exceptionCaught(IoSession ioSession, Throwable cause) {
		cause.printStackTrace();
	}

	@Override
	public void sessionClosed(IoSession ioSession) throws Exception {
	}

	@Override
	public void messageReceived(IoSession ioSession, Object msg) throws Exception {
		HandlerManager.resolveMessage((AbstractC2SMessage)msg,ioSession);
	}

	@Override
	public void messageSent(IoSession session, Object message) throws Exception {
		super.messageSent(session, message);
	}
}
